import functools


def log(func):
    @functools.wraps(func)
    def wrapper(*args, **kw):
        print('call %s():' % func.__name__)
        return func(*args, **kw)

    return wrapper


@log
def hello():
    print('HHHHHHH')


# hello()
f = hello
print(f.__name__)


def log(switch):
    def decorator(func):
        if switch:
            @functools.wraps(func)
            def wrapper(*args, **kw):
                print(' %s():' % (func.__name__))
                return func(*args, **kw)

            return wrapper
        else:
            return func

    return decorator


@log(switch=True)
def test():
    print('yuan..')


# now = log('execute')(test)
# print(now.__name__)

test()
